package com.bjpowernode.web.vo;

/**
 * @description:
 * @author: panDeng_Zhu
 * @time: 2022/10/25 21:27
 * 分页数据类
 */

public class Page {

    //默认的分页大小
    public static final int PAGE_SIZE = 9;

    //页号
    private Integer pageNo;
    //每页数据大小
    private Integer pageSize;
    //总记录数
    private Integer totalRecords;
    //总页数
    private Integer totalPages;

    public Page() {
    }

    public Page(Integer pageNo, Integer pageSize, Integer totalRecords) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.totalRecords = totalRecords;


        if (pageNo == null || pageNo < 1) {
            this.pageNo = 1;
        }
        if (pageSize == null || pageSize == 0) {
            this.pageSize = PAGE_SIZE;
        }
        //计算总页数
        if (this.totalRecords % this.pageSize == 0) {
            this.totalPages = this.totalRecords / this.pageSize;
        } else {
            this.totalPages = this.totalRecords / this.pageSize + 1;
        }
    }


    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(Integer totalRecords) {
        this.totalRecords = totalRecords;
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }
}
